import {homeGoods} from '@/request/goods'
export default {
  namespaced: true,
  state:{
    cache: {}
  },
  mutations: {
    updateCache(state, payload) {
      state.cache[payload.k] = payload.list;
     state.cache = JSON.parse(JSON.stringify(state.cache));
    },
    destoryCache(state) {
      state.cache = {}
    }
  },
  actions: {
    getCacheDate(store, payload) {
      // console.log(payload);
      const params = {
        cate: payload.cate
      }
      // console.log(params);
      homeGoods(params).then(res => {
        // console.log(res);
        store.commit('updateCache', {k:payload.k, list: res.list});
      })
    }
  }
}
